#include<stdio.h>
  
#define SIZE 510  
#define INF 10000000
  
 
int dijkstra(int from, int to,int map[SIZE][SIZE],int price[SIZE][SIZE],int n,int m){	
	
    int i,j;  
    int START =from;
    int parent[SIZE];
    int cost[SIZE];
    int len[SIZE];  
    int visit[SIZE];  
    for(int i =0;i<SIZE;i++)
       parent[i]=START;
    
    for(i = 0 ; i < n  ; i ++){	 
        visit[i] = 0;	
        len[i] = map[from][i];	
        cost[i] = price[from][i];
    }  
   
    for(i = 0 ; i < n ; ++i){	
        int min = INF; 
        int pos;  
  
        for(j = 0 ; j < n ; ++j)
        {	
            if(!visit[j] && min > len[j]){  
                pos = j;  
                min = len[j];  
            }  
        }  
        visit[pos] = 1;  
  
        for(j = 0 ; j < n ; ++j){
            if(!visit[j] && (len[j] > (len[pos] +map[pos][j])))
            { 
                len[j] = len[pos] + map[pos][j];	
                cost[j] = cost[pos] + price[pos][j];
                parent[j]=pos;
            }  
            else if((!visit[j] )&& (len[j] == (len[pos] +map[pos][j]))&&(cost[j] > cost[pos] + price[pos][j] ))
            {
                cost[j] = cost[pos] + price[pos][j];
                parent[j] = pos;
            }
        }  
    }  
    printf("%d %d",len[to],cost[to]);
  
    return len[to];
}
void gen(int map[SIZE][SIZE],int price[SIZE][SIZE],int vertex_num,int edge_num)
{
    int i,j;
    int k;
    int Ver;
    int start,end;
    
    for(i=0;i<vertex_num;i++)
    {
        for(j=0;j<vertex_num;j++)
         map[i][j] = INF;
         price[i][j] = INF;
    }

    for(k=0;k<edge_num;k++)
    {
        scanf("%d%d",&i,&j);
        scanf("%d%d",&map[i][j],&price[i][j]);
        map[j][i] = map[i][j];
        price[j][i] = price[i][j];
    }
}
  
int main () {  
 
    int map[SIZE][SIZE]; 
    int price[SIZE][SIZE];
    int vertex_num; 
    int edge_num;
    int start,end;
    scanf("%d%d",&vertex_num,&edge_num);
    scanf("%d%d",&start,&end);
    gen(map,price,vertex_num,edge_num);

    dijkstra(start,end,map,price,vertex_num,edge_num);

    return 0;  
}

